//
// Created by DonAzufre on 24-4-1.
//
#pragma once

#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "IR.h"
#include "passes.h"


class PassManager
{
    std::vector<std::unique_ptr<Pass>> passes;

public:
    auto registerPass(Pass *p)
    {
        passes.emplace_back(p);
        return passes.size();
    }

    sysy::Module *runPasses(sysy::Module *pModule)
    {
        for (auto &pass : passes)
        {
            pModule = pass->run(pModule);
        }
        return pModule;
    }

    PassManager()
    {
        registerPass(new PreProcess());
        // registerPass(new Mem2Reg());
    }
};

